package com.polaris.live.adapter.party

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterPartyCoverTypeBinding
import com.polaris.live.resp.back_resp.PartyThemeResp

/**
 * PartyThemeTypeAdapter 派对主题
 *
 * @author Created by 天晴 on 2024/9/9/014 22:00
 */
class PartyThemeTypeAdapter : BaseBindingAdapter<AdapterPartyCoverTypeBinding, PartyThemeResp>() {

    private var selectPosition = 0
    override fun convert(holder: VBViewHolder<AdapterPartyCoverTypeBinding>, item: PartyThemeResp) {
        holder.vb.apply {
            partyTypeItemTv.text = item.name
            if (selectPosition == holder.absoluteAdapterPosition) {
                partyTypeSelectBack.visibility = View.VISIBLE
            } else {
                partyTypeSelectBack.visibility = View.GONE
            }
        }
    }

    fun setSelect(position: Int) {
        selectPosition = position
        notifyDataSetChanged()
    }

    fun getSelectItem() = data.getOrNull(selectPosition)

    companion object {

        const val PARTY = 1
        const val VIDEOPARTY = 2
    }
}